package test;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2025/7/16
 * Time: 22:19
 */
public class Solution1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scan.nextInt();
        }
        int[] dp = new int[n];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                // if (prices[i] == 7 && prices[j] == 2) {
                //     System.out.println(prices[i] - prices[j]);
                // }
                dp[i] = Math.max(dp[i - 1], prices[i] - prices[j]);
            }
            System.out.println(dp[i]);
        }
        System.out.println(dp[n - 1]);
    }
}
